home *** CD-ROM | disk | FTP | other *** search
- /****************************************************/
- /* */
- /* File: start.c */
- /* */
- /* Program: ChromaKeyMovie */
- /* */
- /* By: Jason Hodges Harris */
- /* */
- /* Copyright: © 1995 by Apple Computer, Inc., */
- /* all rights reserved. */
- /* */
- /****************************************************/
-
-
- // Mac Toolbox headers
-
- #ifndef __CURSORCTL__
- #include <CursorCtl.h>
- #endif
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
- #ifndef __FONTS__
- #include <Fonts.h>
- #endif
-
- #ifndef __GESTALT__
- #include <Gestalt.h>
- #endif
-
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
-
- #ifndef __MENUS__
- #include <Menus.h>
- #endif
-
- #ifndef __QDOFFSCREEN__
- #include <QDOffscreen.h>
- #endif
-
- #ifndef __SEGLOAD__
- #include <SegLoad.h>
- #endif
-
- #ifndef __TEXTEDIT__
- #include <TextEdit.h>
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __WINDOWS__
- #include <Windows.h>
- #endif
-
-
- // Program headers
-
- #ifndef __CHROMAPPHEADER__
- #include "ChromaKeyMovie.app.h"
- #endif
-
- #ifndef __CHROMAPROTOSHEADER__
- #include "ChromaKeyMovie.protos.h"
- #endif
-
-
- // Global Variables
-
- // Predefined RGBColors
-
- RGBColor kRGBWhite = {0xFFFF,0xFFFF,0xFFFF},
- kRGBBlack = {0x0000,0x0000,0x0000},
- gKeyColor;
- // Chroma keying mode
- short gKeyMode;
- // location of the movie relative to the background image
- Boolean gMovieBackGrnd;
- // Application loop exit test
- Boolean gDone;
- // Movie window open (only one window supported)
- Boolean gMovieOpen;
-
- // declare the QuickDraw globals for PowerMac native build
- #if defined(powerc) || defined(__powerc)
- QDGlobals qd;
- #endif
-
-
- // initialise the global variables
-
- void InitGlobals(void)
- {
- gKeyColor = kRGBBlack; // preset chroma key color to black
- gKeyMode = transparentMode; // default Chroma key mode use transparent transfer mode
- gMovieBackGrnd = false; // movie in foreground
- gDone = false; // set global loop var to false while program active
- gMovieOpen = false; // No window open
- }
-
-
- // Gestalt tests
-
- #pragma segment Main
- void TestforQuickTimeVersion(void)
- {
- long QTimeVersion;
- OSErr error;
- if(Gestalt('qtim',&QTimeVersion) == noErr)
- {
- /* QuickTime version 2.1 or later required for all options to be available.
- If not display a warning dialog and disable QT 2.1 reliant feature */
- if (QTimeVersion < 0x02100000)
- {
- DisplayAlert (rGenWarning,rQTmessages,2);
- DisableItem(GetMHandle(mMode),iModifier);
- }
- // check for the QuickTime shared library loaded as Gestalt not always correct
- #if defined(powerc) || defined(__powerc)
- if (!EnterMovies)
- {
- DisplayAlert(rGenAlert,rQTmessages,3);
- gDone = true;
- return;
- }
- #endif
- error = EnterMovies(); // initialise QuickTime
- if (error != noErr)
- {
- DisplayAlert (rGenAlert,rQTmessages,1);
- gDone = true; // exit application
- }
- return;
- }
- DisplayAlert (rGenAlert,rQTmessages,1);
- gDone = true;
- return;
- }
-
-
- // Main function
-
- #pragma segment Main
- int main(void)
- {
- long *AppSize; // application size
- short i;
-
- AppSize = (long*)(GetApplLimit());
- SetApplLimit (AppSize-32768);
-
- // This decreases the application heap by 32k, which in turn
- // increases the stack by 32k.
-
- MaxApplZone(); // Expand the heap so code segments load at the top.
- for (i=0;i<5;i++)
- MoreMasters(); // allocate more master pointers
-
- // Initialise the toolbox
-
- InitGraf (&qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(0L);
- InitCursor();
-
- InitGlobals(); // initialise globals
- MenuBarInit(); // init menubar
- TestforQuickTimeVersion(); // test for and initialise Quicktime
- DoAdjustMenus(); // menu setup
- EventLoop(); // Call the main event loop.
- ExitToShell(); // Quit the application.
- return 0;
- }
-